package com.atstudy.files;

import java.io.File;
import java.io.IOException;

/**
 * @version v1.0
 * @description:
 * @author: admin
 * @date: 2022/12/29 15:11
 * @copyright: 博为峰
 */
public class FileDemo {
    public static void main(String[] args) throws IOException {
//        m1();
//        m2();
//        m3();
        File dir = new File("C:\\Users\\admin\\Desktop\\java29\\io\\a");
        File[] files = dir.listFiles();
        for (File file : files) {
            System.out.println(file.getName());
        }
    }

    private static void m3() {
        File dir = new File("C:\\Users\\admin\\Desktop\\java29\\io\\a\\b\\c");
//        dir.mkdir();//创建单级目录
//        dir.mkdirs();//创建多级目录

        File file = new File("C:\\Users\\admin\\Desktop\\java29\\io\\a\\b\\c\\c.txt");
//        file.createNewFile();//创建文件

        dir.delete();
    }

    private static void m2() {
        File file = new File("C:\\Users\\admin\\Desktop\\java29\\io\\bos.txt");
        System.out.println("文件名：" + file.getName());
        System.out.println("文件路径：" + file.getPath());
        System.out.println("修改时间：" + file.lastModified());//毫秒值
        System.out.println("文件大小：" + file.length());//字节
    }

    private static void m1() {
        File file = new File("C:\\Users\\admin\\Desktop\\java29\\io\\bos.txt");
        File dir = new File("C:\\Users\\admin\\Desktop\\java29\\io");
    }
}
